#!/usr/bin/python
# coding=utf-8

import plotly.plotly
import pandas as pd


#地图颜色深浅
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')
z = [1,2,3,4,5,6,7,8]
text=["beijing","hebei","henan","shandong","shanghai","jilin","sichuan","tianjin"]
data = [dict(
        type='choropleth',
        locations=df['CODE'],
        z=df['GDP (BILLIONS)'],
        text=df['COUNTRY'],
        colorscale=[[0, "rgb(5, 10, 172)"], [0.35, "rgb(40, 60, 190)"], [0.5, "rgb(70, 100, 245)"],
                    [0.6, "rgb(90, 120, 245)"], [0.7, "rgb(106, 137, 247)"], [1, "rgb(220, 220, 220)"]],
        autocolorscale=False,
        reversescale=True,
        marker=dict(
                line=dict(
                        color='rgb(180,180,180)',
                        width=0.5
                )),
        colorbar=dict(
                tickprefix='$',
                title='GDP<br>Billions US$'),
)]

layout = dict(
        title='2014 Global GDP<br>Source:\
            <a href="https://www.cia.gov/library/publications/the-world-factbook/fields/2195.html">\
            CIA World Factbook</a>',
        geo=dict(
                showframe=False,
                showcoastlines=False,
                projection=dict(
                        type='Mercator'
                )
        )
)

fig = dict(data=data, layout=layout)
plotly.offline.plot(fig, filename="3333.html")
